package com.study.cloudAlibaba.controller;

import com.study.cloudAlibaba.domain.Account;
import com.study.cloudAlibaba.domain.CommonResult;
import com.study.cloudAlibaba.service.AccountService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.awt.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author lzc
 * @date 2022/7/29 16:22
 */
@RestController
public class AccountController {
    @Resource
    private AccountService accountService;

    /**
     * 扣减账户余额
     */
    @RequestMapping("/account/decrease")
    public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        accountService.decrease(userId,money);
        return new CommonResult(200,"扣减账户余额成功！");
    }

    @RequestMapping("/account/list")
    private CommonResult<Account> list(){
        List<Account> list = accountService.list();
        return new CommonResult(200,"success",list);
    }
}
